package com.xfzp.d3;

/**
 * 用RGB和透明度表示的颜色。
 * 
 * @author AndroidApe
 * @version 2011-10-13
 */
public class Color {
	public final static Color BALCK = new Color(0, 0, 0);
	public final static Color WHITE = new Color(1, 1, 1);
	public final static Color RED = new Color(1, 0, 0);
	public final static Color GREEN = new Color(0, 1, 0);
	public final static Color BLUE = new Color(0, 0, 1);
	public final static Color YELLOW = new Color(1, 1, 0);
	public final static Color ORANGE = new Color(1, 0.5f, 0);

	public final float r;// 红色
	public final float g;// 绿色
	public final float b;// 蓝色
	public final float a;// 透明度

	public Color(float r, float g, float b) {
		this.r = r;
		this.g = g;
		this.b = b;
		this.a = 1;
	}

	public Color(float r, float g, float b, float a) {
		this.r = r;
		this.g = g;
		this.b = b;
		this.a = a;
	}

	/**
	 * 克隆此颜色
	 */
	public Color clone() {
		return new Color(r, g, b, a);
	}

	/**
	 * 测试两个颜色实例是否是同一颜色
	 * 
	 * @param c
	 * @return
	 */
	public boolean same(Color c) {
		return r == c.r && g == c.g && b == c.b && a == c.a;
	}
}
